package com.hnhuas.salary.modules.admin.controller;

import cn.hutool.core.lang.Console;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.sax.Excel07SaxReader;
import cn.hutool.poi.excel.sax.handler.RowHandler;
import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * Created by weirdor on 2019-09-03 16:57
 */
public class ExcelTest {

    public static void main(String[] args) throws IOException {

        Excel07SaxReader excel07SaxReader= ExcelUtil.read07BySax("/Users/weirdor/Downloads/2019年8月工资.xlsx", 0, createRowHandler());

        ExcelReader reader = ExcelUtil.getReader("/Users/weirdor/Downloads/2019年8月工资.xlsx");
        List<Map<String,Object>> readAll = reader.readAll();
        System.out.println(readAll);
    }
    private static RowHandler createRowHandler() {
        return new RowHandler() {
            @Override
            public void handle(int sheetIndex, int rowIndex, List<Object> rowlist) {
                if (rowIndex>=5){
                    Console.log("[{}] [{}] {}", sheetIndex, rowIndex, rowlist);
                }

            }
        };
    }
}
